<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class ContactRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            "name" => "required|max:10|min:2",
            "mobile_phone" => "required|is_mobile_phone",
            "birth_date" => "required|is_past:18",
            "email" => "required|email"
        ];
    }

    public function messages(){
        return [
            "*.required" => "这是必填字段",
            "email.email" => "必须是合法的电邮地址",
            "mobile_phone.is_mobile_phone" => "必须是正确的手机号格式",
            "birth_date.is_past" => "出生年月必须在 :years 年前（:date 前）"
        ];
    }
}
